home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 1 / ETO Development Tools 1.iso / Essentials / Developer Essentials Jul 90 / Programming / MPW Dynamo 3.0 / v3.0 changes < prev   
Encoding:
Text File  |  1990-03-17  |  9.8 KB  |  232 lines  |  [TEXT/MPS ]

  1. Dynamo 3.0 changes:
  2.  
  3.  
  4.  
  5. I have been busy changing things for no reason at all, and here's where I stand:
  6. (This is a joke.  I had reasons.  I just can't remember what they were.)
  7. ((This is a joke.))
  8.  
  9.  
  10. 1)    BUILDAPP.SYSTEM has changed.  The new build script sample looks like this:
  11.  
  12. DUMMY                            ;The default script filename.
  13. 0,$0800,SAMPLE.BIN                ;Sample app, segment 1 (on server).
  14. 0,$8000,SAMPLE.BIN.2            ;Sample app, segment 2 (on server).
  15. 0,$9000,SAMPLE.BIN.3            ;Sample app, segment 3 (on server).
  16. $80,$800                        ;Starting address.
  17. $                                ;Display starting address in hex.
  18. $                                ;Display application size in hex.
  19. N                                ;Skip save file prompt (and don't save it).
  20. $FF,0,SAMPLE.SYSTEM                ;Target filename, filetype, and auxtype.
  21.  
  22. The difference is the 8th line.  This is new.  You don't have to be prompted from
  23. the keyboard anymore.  You can put a Y,N, or Q here instead of typing it.  If you
  24. don't put one of these letters (lowercase is okay, too), then you will be prompted
  25. from the keyboard.  As a convention, I recommend a ? if you want to be prompted.
  26.  
  27.  
  28. 2)    The runtime and macros have been revised a few times lately.  One of these
  29.     changes was to optimize _decout, _add, _sub, _mul, _div, _set, _index,
  30.     _getb, _getw, _putb, and _putw.  This was a bad idea, since it makes it
  31.     even more difficult to do Dynamo versions for other assemblers and keep
  32.     them as compatible as possible.  This feature in the MPW version caused
  33.     a greater leel of incompatibility, so I have removed it.  There is a
  34.     benefit that remained.  There were some entry points added for the array
  35.     indexing and accessing routines for the optimizations.  These entry points
  36.     are still there.  Given that _index, _getb, _getw, _putb, and _putw are no
  37.     longer figuring out which entry point to call, there have been some macros
  38.     added.  These are (logically enough) _indexl, _getbl, _getwl, _putbl, and
  39.     _putwl.  These don't load a 2-byte constant into the accumulator and
  40.     y-register.  Rather, they load a one byte value into the accumulator and
  41.     then call the alternate entry point (which loads the accumulator with 0
  42.     and branches to the regular entry point).  If you have a constant in the
  43.     range 0-255, as an optional syntax, you can still call _getb, _getw, _putb,
  44.     and _putw, as long as you put a < in the constant parameter to indicate it
  45.     is a 1-byte value.  For _index, this is the ONLY way to just load the
  46.     accumulator and call the alternate entry point.  There is no _indexl
  47.     macro.  The reason for this is that you can have multiple indexes for
  48.     one instance of _index, so each parameter needs to demonstrate if it is
  49.     a 1-byte or 2-byte value.  Some syntax examples would be:
  50.         _index        #345,,<#3
  51.         _getw        var1,<#3
  52.  
  53.     A constant parameter can now take these following forms and it produces
  54.     the following code:
  55.         1)    = #constant
  56.                 lda #<constant
  57.                 ldy #>constant
  58.         2)    = *address
  59.                 lda address
  60.                 ldy address+1
  61.         3)    = #<constant
  62.                 lda #<constant
  63.         4)    = *<address
  64.                 lda address
  65.  
  66.     As a sample we want to calculate the number of bytes necessary to store a
  67.     rectangle of data on the screen.  We have a rectangle stored at $4000, in
  68.     the form x1,y1,x2,y2.  The x-values take two bytes (0-280), and the y-values
  69.     take 1 byte (0-192).  How many bytes do this take?
  70.         First, we calculate which row we are starting in.
  71.  
  72.         The formula is:  bytes = (int((x2 + 6) / 7) - int(x1 / 7) * (y2 - y1)
  73.         The macros to do this formula would look like:
  74.  
  75.             rect    equ        $4000
  76.             x1        equ        0
  77.             y1        equ        2
  78.             x2        equ        3
  79.             y2        equ        5
  80.  
  81.     1)                _set    temp,*rect+x1        ;temp = x1
  82.     2)                _div    ,#<7                ;temp = int(x1 / 7)
  83.     3)                _set    bytes,*rect+x2        ;bytes = x2
  84.     4)                _add    ,#<6                ;temp = x2 + 6
  85.     5)                _div    ,#<7                ;bytes = int((x2 + 6) / 7)
  86.     6)                _subvar    ,temp                ;bytes = bytes - temp
  87.                                                 ;We now have # of bytes wide (in bytes).
  88.     7)                _set    temp,*<rect+y2        ;temp = y2
  89.     8)                _sub    ,*<rect+y1            ;temp = y2 - y1
  90.     9)                _mul    bytes,temp            ;bytes = bytes * temp
  91.  
  92.         The code for these macros would look like:
  93.     1)                ldx        #temp
  94.                     lda        rect+x1
  95.                     ldy        rect+x1+1
  96.                     jsr        setcon                ;Set temp to a 2-byte value.
  97.  
  98.     2)                lda        #<7
  99.                     jsr        divconl                ;Divide temp by a 1-byte constant.
  100.  
  101.     3)                ldx        #bytes
  102.                     lda        rect+x2
  103.                     ldy        rect+x2+1
  104.                     jsr        setcon                ;Set bytes to a 2-byte value.
  105.  
  106.     4)                lda        #<6
  107.                     jsr        addconl                ;Add a 1-byte constant to bytes.
  108.  
  109.     5)                lda        #<7
  110.                     jsr        divconl                ;Divide bytes by a 1-byte constant.
  111.  
  112.     6)                ldy        #temp
  113.                     jsr        subvar                ;Subtract temp from bytes.
  114.  
  115.     7)                ldx        #temp
  116.                     lda        rect+y2
  117.                     jsr        setconl                ;Set temp to a 1-byte value.
  118.  
  119.     8)                lda        rect+y1
  120.                     jsr        subconl                ;Subtract a 1-byte value from temp.
  121.  
  122.     9)                ldx        #bytes
  123.                     ldy        #temp
  124.                     jsr        mulvar                ;bytes = bytes * temp
  125.  
  126.         Since the y-values are only 1 byte, it is less code to write steps 7-9 like this:
  127.                     lda        rect+y2
  128.                     sec
  129.                     sbc        rect+y1
  130.                     _mull
  131.         Note that bytes didn't have to be redeclared for the multiply.  It is still
  132.         around from step 3.  (Steps 4 thru 6 start with a comma, thus leaving the
  133.         x-register alone.)  Also note that we said _mull, NOT _mul.  Since we are
  134.         not stating what we are multiplying by, we aren't telling the macros how
  135.         big the value is.  Since it doesn't know, it has to assume we know what we
  136.         are doing.  If we said _mul, it would assume that we wanted to multiply by
  137.         a 2-byte value, and the y-register would hold the hi-byte.  That isn't what
  138.         we want in this case.  We want to multiply by a 1-byte value, so we have to
  139.         use the _mull macro instead.  This needs to be watched carefully!! 
  140.  
  141.         So, we used the macros when it helped (readability and/or code size) and wrote
  142.         regular assembly code when it was easy and smaller.  The best of both worlds!!
  143.  
  144.  
  145. 3)    Another runtime change that stayed in is a value called strvalcount.  This
  146.     value is calculated by _strval and _midstrval.  strvalcount is the number
  147.     of characters involved in the evaluation of the string value.  Some examples:
  148.  
  149.         _strval of:  -$100FG                            returns -4111 (or 61425) 
  150.                                                         and sets strvalcount to 6.
  151.  
  152.         _midstrval(from char 4) of:  ------345.6789        returns 345 (two minuses
  153.                                                         cancel each other out) and
  154.                                                         sets strvalcount to 5.
  155.  
  156.     This addition is very useful when parsing a string.  If you pull an integer
  157.     value from a string, you may want to know how many characters the runtime
  158.     routine used.  If this value wasn't set, you would have to know all of the
  159.     rules that the runtime used to evaluate the integer and walk through the
  160.     string again yourself.  This is wasteful, and also can be a problem if the
  161.     evaluation method is ever changed.  If that occured, you would have to change
  162.     code in more than one place.  strvalcount is not returned in any register.
  163.     The registers are all used already.  Also, you commonly don't care about this
  164.     value.  (When you do care, you need it badly.)  strvalcount is simply a byte
  165.     value that you have external access to.  If you want it, just load it.
  166.  
  167.  
  168. 4)    Another _strval or _midstrval calculated value is strvaldigit.  This tells
  169.     you if the string evaluation routine actually found any digits.  When you
  170.     are returned a value of 0, you don't know if this was because there was a
  171.     value of 0 (or -$0000 for that matter), or because the routine ran into a
  172.     non-integer character before it could find any characters to evaluate.  The
  173.     strvaldigit value tells you which occured.  It holds the number of digit
  174.     characters encountered.  (If strvaldigit is 0, then the integer result must
  175.     also be 0.)  Note that strvalcount can be greater than 0 even if strvaldigit
  176.     is 0.  This would occur in the string: -$G  In this case strvalcount would be
  177.     2 (the - and the $) and strvaldigit would be 0 (there were no legal digits).
  178.  
  179.  
  180. 5)    Another change (kind of big, kind of small) is how the variable space is
  181.     defined.  It used to be that varstart was equated in app.config.  If it
  182.     changed, the runtime has to be reassembled and turned into a library again.
  183.     This has been leading to errors that are time consuming to trace.  Instead,
  184.     what is being done is to let the linker worry about it.  There now needs to
  185.     be a varspace space (256 bytes) for the linker to link in.  Once this is
  186.     done, varspace can be kept, or you can use LinkIIGS and MakeBigIIGS to throw
  187.     it away.  The runtime doesn't demand that varspace be part of your program.
  188.     All it cares about is that there are 256 bytes somewhere in memory that it
  189.     will access.  So, it isn't necessary that the application carry these 256
  190.     bytes around.  (Save disk space -- just say no!!)  It is necessary to have
  191.     something for the linker to work with, however.  So, the sample application
  192.     now has an additional segment called varspace.  It is thrown away in this
  193.     example.  This is done by linking it into a separate segment that we don't
  194.     care about.  Check out the make file for exactly how this is done.
  195.     It is worth noting that if you wish to move where the 256-byte varspace
  196.     area is, all you need to do is change the makefile.  Just change the -org
  197.     value for the segment "trash".
  198.  
  199. 6)    More support for indirection and dereferencing has been added.  There are now
  200.     an additional macro for dereferencing, as well as syntax extensions to handle
  201.     multi-level-dereferencing in conjunction with other macros.  Here is some code
  202.     from sample.a that demonstrates the extent of the indirection capabilities:
  203.  
  204.         _set    var1,**@ptr1        ;Set var1 to double-dereferenced @ptr1.
  205.                                     ;var1 has address @ptr3 now.
  206.         _add    ,#<2                ;Add 2 to the pointer.
  207.         _vderef                        ;Dereference var1 again (into itself).
  208.                                     ;var1 has address @ptr4 now.
  209.         _vderef                        ;Dereference var1 again (into itself).
  210.                                     ;var1 has address @ptr5 now.
  211.         _vderef                        ;Dereference var1 again (into itself).
  212.                                     ;var1 has value from @ptr5 now.
  213.         _vhexout                    ;Output the variable value (which is $1234)
  214.         jmp        @past
  215.  
  216. @ptr1        dc.w    @ptr2
  217. @ptr2        dc.w    @ptr3
  218. @ptr3        dc.w    0,@ptr4
  219. @ptr4        dc.w    @ptr5
  220. @ptr5        dc.w    $1234
  221.  
  222. @past        equ        *
  223.  
  224.  
  225.  
  226.  
  227. Well, this ought to be enough arbitrary changes for version 3.0 -- have fun.
  228.  
  229.  
  230.  
  231. Eric Soldan, Apple II DTS
  232.